﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;

namespace BLL.Object
{
   public class GiaoVien
    {
       public int ID{get;set;}
       public string MaGV{get;set;}
       public string TenGV{get;set;}
       public string Email{get; set;}

       //////////////////////////////////////////////////////////////////////////'
       public static List<GiaoVien> All()
       {
           return CBO.FillCollection<GiaoVien>(DataProvider.Instance.ExecuteReader("GiaoVien_SelectAll"));
       }

       //Them GV
       public static bool Add( GiaoVien gv)
       {
           try
           {
               object rs = DataProvider.Instance.ExecuteNonquery("GiaoVien_Insert", 0, gv.MaGV, gv.TenGV, gv.Email);
               return Convert.ToInt32(rs) >0;
           }
           catch 
           {
               return false;
           }
           

       }
       //Cập Nhật GV
       public static bool Update(GiaoVien gv)
       {
           try
           {
               object rs = DataProvider.Instance.ExecuteNonquery("GiaoVien_Update", gv.ID, gv.MaGV, gv.TenGV, gv.Email);
               return Convert.ToInt32(rs) > 0;
           }
           catch
           {
               return false;
           }


       }

       //Xóa GV
       //Cập Nhật GV
       public static bool Delete(int gvID)
       {
           try
           {
               object rs = DataProvider.Instance.ExecuteNonquery("GiaoVien_Delete",gvID);
               return Convert.ToInt32(rs) > 0;
           }
           catch
           {
               return false;
           }


       }
    }
}
